package com.gurun.codes.base;


import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;

import com.gurun.codes.business.common.ListContentViewBinder;
import com.gurun.codes.business.common.ListTitleViewBinder;
import com.gurun.codes.views.EmptyRecyclerView;
import com.gurun.model.bean.common.ListContentModel;
import com.gurun.model.bean.common.ListTitleModel;

import me.drakeet.multitype.Items;
import me.drakeet.multitype.MultiTypeAdapter;

public abstract class BaseRecyclerViewActivity extends BaseAppCompatActivity {
    protected MultiTypeAdapter mAdapter;
    protected Items mDatas = new Items();

    protected void initRevyclerView(EmptyRecyclerView emptyRecyclerView, View emptyview){
        mAdapter = new MultiTypeAdapter();
        mAdapter.register(ListTitleModel.class, new ListTitleViewBinder(mContext));
        mAdapter.register(ListContentModel.class, new ListContentViewBinder(mContext));
        emptyRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        emptyRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mAdapter.setItems(mDatas);
        emptyRecyclerView.setAdapter(mAdapter);
        emptyRecyclerView.setEmptyView(emptyview);
    }
}
